using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;

namespace VisitWebSite
{
  public static class clsHttpUtil
  {
    public static bool DownLoadXMLFile(string url, string LocalPath)
    {
      try
      {
        Uri u = new Uri(url);
        HttpWebRequest mRequest = (HttpWebRequest)WebRequest.Create(u);
        mRequest.Method = "GET";
        //mRequest.ContentType = "text/html";

        HttpWebResponse wr = (HttpWebResponse)mRequest.GetResponse();

        Stream sIn = wr.GetResponseStream();
        //FileStream fs = new FileStream(LocalPath, FileMode.OpenOrCreate, FileAccess.Write);
        StreamReader sr = new StreamReader(sIn,Encoding.UTF8);
        string content = sr.ReadToEnd();
        File.WriteAllText(LocalPath,content);

        sIn.Close();
        wr.Close();
        return true;
      }
      catch { return false; }
    }
  }
}
